<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <script src="../../vue.js"></script>
</head>

<body>
  <div id="app">
    <gp-counter></gp-counter>
    <gp-counter></gp-counter>
    <gp-counter></gp-counter>
  </div>

  <script type="text/template" id="counterTemp">
    <div>
    <h1>gp-counter</h1>
    <div>
      <button @click="count -= 1">-</button>
      {{count}}
      <button @click="increment(1)">+</button>
    </div>
  </div>
  </script>

  <script>
    // 全局组件
    Vue.component('gp-counter', {
      template: "#counterTemp",
      data() {
        return {
          count: 0
        }
      },
      methods: {
        increment(num) {
          this.count += num;
        }
      }
    })

    var vm = new Vue({
      el: "#app"
    })




  </script>

</body>

</html>